package com.example.provider3.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/provider")
public class Provider3Controller {

    @Value("${server.port}")
    private String serverPort;

    @Value("${spring.application.name}")
    private String applicationName;

    @GetMapping("/hello")
    public Map<String, Object> hello() {
        Map<String, Object> result = new HashMap<>();
        result.put("message", "Hello from Provider Service 3!");
        result.put("serverPort", serverPort);
        result.put("applicationName", applicationName);
        result.put("timestamp", System.currentTimeMillis());
        return result;
    }

    @GetMapping("/info")
    public Map<String, Object> getInfo() {
        Map<String, Object> result = new HashMap<>();
        result.put("serviceName", applicationName);
        result.put("port", serverPort);
        result.put("status", "UP");
        result.put("instanceId", applicationName + ":" + serverPort);
        return result;
    }
} 